package top.xmj.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Random;

/**
 * @author 冰咖啡
 * Date:3/12/2022 下午 9:25
 * Description: 生成随机验证码
 */
@Component
public class VerificationCodeUtil {

    public String VerificationCode(){
        String str="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        int codeLength=6;
        StringBuilder sb=new StringBuilder(6);
        for(int i=0;i<codeLength;i++)
        {
            char ch=str.charAt(new Random().nextInt(str.length()));
            sb.append(ch);
        }
        return (sb.toString());
    }
}
